package com.allwees.bs.module.pms.wf;

import com.baomidou.mybatisplus.core.enums.IEnum;
import com.allwees.core.wf.FsmState;
import com.allwees.core.wf.Transition;

import java.util.Arrays;
import java.util.List;

/**
 * 零售商商品上架流程状态机
 *
 * @author yangylsky
 * @since 2019-12-09
 *
 */
public enum ERetailerProductState implements FsmState<ERetailerProductState, ERetailerProductAction>, IEnum<String> {
	START("Start", false, false) {
		@Override
		public List<Transition<ERetailerProductState, ERetailerProductAction>> getTransitions() {
			return Arrays.asList(
				new Transition<>(ERetailerProductAction.RETAILER_COMMIT, WAIT_AUDIT),
				new Transition<>(ERetailerProductAction.RETAILER_ADJUST_PRICE, WAIT_AUDIT)
			);
		}
	},

	WAIT_AUDIT("待审核",true, false) {
		@Override
		public List<Transition<ERetailerProductState, ERetailerProductAction>> getTransitions() {
			return Arrays.asList(
				new Transition<>(ERetailerProductAction.RETAILER_CANCEL, CANCELED),
				new Transition<>(ERetailerProductAction.PLATFORM_AUDIT_REJECTED, MODIFY),
				new Transition<>(ERetailerProductAction.PLATFORM_AUDIT_APPROVED, COMPLETED)
			);
		}
	},

	MODIFY("需修改", true, false) {
		@Override
		public List<Transition<ERetailerProductState, ERetailerProductAction>> getTransitions() {
			return Arrays.asList(
				new Transition<>(ERetailerProductAction.RETAILER_COMMIT, WAIT_AUDIT),
				new Transition<>(ERetailerProductAction.RETAILER_CANCEL, CANCELED)
			);
		}
	},

//	WAIT_CONFIRM("待确认", true, false) {
//		@Override
//		public List<Transition<ERetailerProductState, ERetailerProductAction>> getTransitions() {
//			return Arrays.asList(
//				new Transition<>(ERetailerProductAction.PLATFORM_CONFIRM_PUTON, COMPLETED)
//			);
//		}
//	},

	CANCELED("已撤销", false, true),

	COMPLETED("已完成", false, true);

	/**
	 * 状态描述
	 */
	private String desc;

	private boolean started;

	private boolean ended;

	public String desc() {
		return desc;
	}

	@Override
	public boolean started() {
		return started;
	}

	@Override
	public boolean ended() {
		return ended;
	}

	ERetailerProductState(String desc, boolean started, boolean ended) {
		this.desc = desc;
		this.started = started;
		this.ended = ended;
	}

	@Override
	public String getValue() {
		return name();
	}
}
